﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Model.Util;
using Model.WeiXin;
using Services.WeiXinProject;
using Xproject.Util;
using Services.ZXBuiness;
using Model.ZXBuiness;
namespace WeiXinpProAdmin.Controllers
{
    public class FinanceController  : AdminBaseController
    {

        public ZXTiXianServices m_ZXTiXianServices;
        public FinanceController(ZXTiXianServices mZXTiXianServices)
        {
            m_ZXTiXianServices = mZXTiXianServices;
        }

        // GET: Finance
        public ActionResult Index()
        {
            return View();
        }

        public ActionResult TiXianApplyList()
        {
            return View();
        }
        public JsonResult AdminGetTXApplyList(int offset, int limit, string ApplyUserCode)
        {
            var lstRes = new List<ZXTiXianApplyModel>();
            int total = 0;
            lstRes = m_ZXTiXianServices.GetTXapplyList( offset, limit, ApplyUserCode, out total);
            return Json(new { total = total, rows = lstRes }, JsonRequestBehavior.AllowGet);
        }
        [HttpPost]
        public JsonResult ApproveThisApply()
        {
            var jsonData = new Object();
            bool success = false;
            string message = "";
            string TiXianId = Request.Form["TiXianId"];
            int result =m_ZXTiXianServices.ApproveThisApply(TiXianId, this.CurrentUser.UserName, "");
            if (result == 0)
            {
                message = "系统出现异常。";
                LogHelper.WriteInfoLog(message + TiXianId);
            }
            if (result == 1)
            {
                message = "审核成功";
                success = true;
            }
            if (result == 2)
            {
                message = "提现id不存在";                
            }
            jsonData = new { Success = success, Data = message };
            return Json(jsonData, JsonRequestBehavior.AllowGet);
        }

        [HttpPost]
        public JsonResult RejectThisApply()
        {
            var jsonData = new Object();
            bool success = false;
            string message = "";
            string TiXianId = Request.Form["TiXianId"];
            string remarks = Request.Form["remarks"];
            int result = m_ZXTiXianServices.RejectThispply(TiXianId, this.CurrentUser.UserName, remarks);
            if (result == 0)
            {
                message = "系统出现异常。";
                LogHelper.WriteInfoLog(message + TiXianId);
            }
            if (result == 1)
            {
                message = "拒绝成功";
                success = true;
            }
          
            jsonData = new { Success = success, Data = message };
            return Json(jsonData, JsonRequestBehavior.AllowGet);
        }
    }
}